#define  _CRT_SECURE_NO_WARNINGS
#include <string>
using std::string;

class Solution {
public:
    int firstUniqChar(string s) {
        size_t hash[128] = { 0 };
        for (auto ch : s)
            hash[ch]++;
        for (int i = 0; i < s.size(); i++)
        {
            if (hash[s[i]] == 1)
                return i;
        }
        return -1;
    }
};